//
//  UIView+NightManager.m
//  ProjectA
//
//  Created by dllo on 16/1/25.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "UIView+NightManager.h"
#import "ColorMacro.h"
#define ISNIGHT [[NSUserDefaults standardUserDefaults] boolForKey:@"IsNight"]
@implementation UIView (NightManager)
+ (void)setColorWithLabelText:(UILabel *)label nightColor:(UIColor *)nightColor dayColor:(UIColor *)dayColor {
    
    if (ISNIGHT) {
        label.textColor = nightColor;
    } else {
        label.textColor = dayColor;
    }
    
}

+ (void)setColorWithLabelView:(UILabel *)label nightColor:(UIColor *)nightColor dayColor:(UIColor *)dayColor {
    if (ISNIGHT) {
        label.backgroundColor = nightColor;
    } else {
        label.backgroundColor = dayColor;
    }
}

+ (void)setColorWithView:(UIView *)view nightColor:(UIColor *)nightColor dayColor:(UIColor *)dayColor {
    if (ISNIGHT) {
        view.backgroundColor = nightColor;
    } else {
        view.backgroundColor = dayColor;
    }
}

+ (void)setColorWithView:(UIView *)view {
    if (ISNIGHT) {
        view.backgroundColor = L_COLOR_GRAY;
    } else {
        view.backgroundColor = RGBA(44, 211, 209, 1);
    }
    
}

+ (void)setColorWithView:(UIView *)view nightColor:(UIColor *)nightColor dayColorWithRed:(CGFloat)r2 green:(CGFloat)g2 blue:(CGFloat)b2 alpha:(CGFloat)a2 {
    if (ISNIGHT) {
        view.backgroundColor = nightColor;
    } else {
        view.backgroundColor = RGBA(r2, g2, b2, a2);
    }
}

+ (void)setColorWithButton:(UIButton *)button nightColor:(UIColor *)nightColor dayColor:(UIColor *)dayColor {
    if (ISNIGHT) {
        [button setTitleColor:nightColor forState:UIControlStateNormal];
    } else {
        [button setTitleColor:dayColor forState:UIControlStateNormal];
    }
}

+ (void)setColorWithTextField:(UITextField *)textField nightColor:(UIColor *)nightColor dayColorWithRed:(CGFloat)r2 green:(CGFloat)g2 blue:(CGFloat)b2 alpha:(CGFloat)a2 {
    if (ISNIGHT) {
        textField.backgroundColor = nightColor;
    } else {
        textField.backgroundColor = RGBA(r2, g2, b2, a2);
    }
}

+ (void)setColorWithLabelView:(UILabel *)label nightColorWithRed:(CGFloat)r1 green:(CGFloat)g1 blue:(CGFloat)b1 alpha:(CGFloat)a1 dayColorWithRed:(CGFloat)r2 green:(CGFloat)g2 blue:(CGFloat)b2 alpha:(CGFloat)a2 {
    if (ISNIGHT) {
        label.backgroundColor = RGBA(r1, g1, b1, a1);
    } else {
        label.backgroundColor = RGBA(r2, g2, b2, a2);
    }
}
@end
